
import React from 'react'
import axios from 'axios'
import { useState } from 'react';
import { useEffect } from 'react'

export default function Index() {
  let [todoList, setToDoList] = useState([])
  let [done, setDone] = useState(false)
  useEffect(() => {
    axios.get("/api/gettodoList").then((res) => {
      // console.log(res.data);
      setToDoList(res.data);
      // console.log(todoList);
    })

  }, []);
  const changeCheck = (e) => {
    setDone(e.target.checked)

  };
  const removeTodo = (e) => {

  }
  return (
    <div>
      {todoList.map((item, key) =>
        <li key={key} >
          <input checked={done} onChange={(e) => { changeCheck(e, key) }} type="checkbox" />
          <span>{item.name}</span>
          <button className='del' onClick={removeTodo}>删除</button>
        </li>


      )
      }
    </div >
  )
}
